package com.roger.security.controller;

import com.roger.security.domain.SUser;
import com.roger.security.utils.DateUtils;
import com.roger.security.utils.JwtUtils;
import org.springframework.web.bind.annotation.*;

/**
 * 1.login接口生成 jwt
 * 2.test接口  拦截器拦截test接口进行jwt验证
 *
 * @author Roger
 * @since 2021/7/13
 */
@RestController
@RequestMapping("/v1")
public class LoginController {


    @PostMapping(value = "/login")
    public String login(@RequestBody SUser sUser){
        String jwt = JwtUtils.sign(sUser.getUsername(), DateUtils.getCurrentTime());
        return jwt;
    }

    @RequestMapping(value = "/test", method = RequestMethod.GET)
    public String test(){

        return "验证通过";
    }
}
